package com.liu.File;
import org.junit.Test;

import java.io.FileInputStream;
import java.io.IOException;

public class FileInputStream_ {
    public static void main(String[] args) {

    }
    @Test
    public void readFile(){
        String filePath = "d:\\news1.txt";
        int readLen = 0;
        byte[] bytes = new byte[8];
        FileInputStream fileInputStream = null;
        try {
              fileInputStream = new FileInputStream(filePath);
             while ((readLen = fileInputStream.read(bytes)) != -1) {
                 System.out.print(new String(bytes,0,readLen));
             }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }finally {
            try {
                fileInputStream.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
